﻿namespace ETestIT.UI.AppControls
{
    using System;
    using System.Web.UI;
    using Domain.Entities;
    using Domain.Repositories;
    using Presentation;
    using StructureMap;

    public partial class ResumeAddUpdate : UserControl
    {
        public event EventHandler Update;
        IJobTitleRepository jobTitleRepository;


        protected void Page_Load(object sender, EventArgs e)
        {
            jobTitleRepository = ObjectFactory.GetInstance<IJobTitleRepository>();

            if (!IsPostBack)
            {
                ddlJobTitles.DataSource = jobTitleRepository.GetAll();
                ddlJobTitles.DataValueField = "Id";
                ddlJobTitles.DataTextField = "Name";
                ddlJobTitles.DataBind();
            }
        }

        protected void btnUpload_Clicked(object sender, EventArgs e)
        {
            if (Update != null)
                Update(sender, e);
        }

        public Guid SelectedJobTitle
        {
            get { return new Guid(ddlJobTitles.SelectedValue); }
        }

        public void SetModel(Resume resume)
        {
        }

        public void UpdateModel(Resume resume)
        {
            // TODO: add title here
            theUploadFileContr.GetResumeContentFromRequest(resume);
        }
    }
}